#include <stdio.h>

int main(void)
{
    int n,a,b,c;
    int boo = 1;

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d",&a,&b,&c);
        for (int x = 1000;x>=1000&&x<=9999; x++)
        {
            if (x%a==0&&(x+1)%b==0&&(x+2)%c==0)
            {
                printf("%d\n",x);
                break;
                boo = 0;
            }
            if (x==9999&&boo==1)
            {
                printf("Impossible\n");
            }
        }
        boo = 1;   
    }
} 
